Subject: [Instant-dev] [HG instant] Fix for not using cache, ffc should be fine.

From: [email-masked] (Instant)
Date: Tue, 12 Aug 2008 13:37:22 +0200 (CEST)

One or more new changesets pushed to the primary instant repository.
A short summary of the last three changesets is included below.

changeset:   186:7d67e6c4ce68fb02e630666441441d9b4741fbf1
tag:         tip
user:        Ilmar Wilbers <[email-masked]>
date:        Tue Aug 12 13:37:20 2008 +0200
files:       src/instant.py
description:
Fix for not using cache, ffc should be fine.

changeset:   185:4a50453449dbfc52ed74f68231ff9462406215c5
user:        Ilmar Wilbers <[email-masked]>
date:        Tue Aug 12 13:12:18 2008 +0200
files:       src/instant.py tests/clean.sh tests/run_tests.sh
description:
Add option for USE_CACHE, remove COPY_LOCAL_FILES. Will ikely break ffc and sfc.

changeset:   184:1a885af5f39890efc316f1b5afd2cd1afc5fd77b
parent:      183:11b02c44a7988427f7b07eea95bbb701a83a7aa3
parent:      182:af9a743fe2c784df274771149f74ac05a175f169
user:        Ilmar Wilbers <[email-masked]>
date:        Mon Aug 11 17:45:55 2008 +0200
files:       etc/instant-clean
description:
Trying to fix mess.

----------------------------------------------------------------------
For more details, visit http://www.fenics.org/hg/instant

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Tue, 12 Aug 2008 14:03:44 +0200

A great feature would be the ability to optionally specify your own
cache directory to create_extension. Then FFC and SFC can use the
cache implementation from Instant, but keep their own data
directories. Also, since the cache is filebased, it should make it
possible to add the cache or parts of it to a source repository for a
particular application, useful for heavy forms with high cost of code
generation (even more so with optimized generated code).

-- 
Martin

2008/8/12 Instant <[email-masked]>:
> _______________________________________________
> Instant-dev mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/instant-dev
>

---

From: Ilmar Wilbers <[email-masked]>
Date: Tue, 12 Aug 2008 14:07:18 +0200

Sure, I agree. I don't think this should pose any problems.

Promise to look into it next week, will be gone for the remaining of 
this one.

ilmar

---

From: Kent-Andre Mardal <[email-masked]>
Date: Tue, 12 Aug 2008 14:14:42 +0200

OK, lets do that. 

So, 

cache_dir is per default .instant 
cache_dir can be set in the create_extension function

instant-clean only remove the .instant directory 

OK ?

Kent

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Tue, 12 Aug 2008 14:30:45 +0200

Great.

-- 
Martin

---

From: Ilmar Wilbers <[email-masked]>
Date: Thu, 28 Aug 2008 11:41:37 +0200

This should be possible now:

           - B{use_cache}:
              - Indicate if you want to store the generated module for 
later use.
                If a bool or int is given that is evaluated as True, the
                default cache directory will be used. To specify a cache
                directory, a string with with the path relative to the 
current path is used.

FFC's JIT should not need any changes, but I made some minor changes so 
that is uses instant as intended.

ilmar

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Mon, 1 Sep 2008 12:59:52 +0200

Suggestion: Use 'd = tempfile.mkdtemp("instant")' to create temporary directory.
This way multiple processes and multiple users can't mess up things.

-- 
Martin

2008/8/28 Ilmar Wilbers <[email-masked]>:
>             - Indicate if you want to store the generated module for later
> use.
>               directory, a string with with the path relative to the current
> path is used.
>
> FFC's JIT should not need any changes, but I made some minor changes so that
> is uses instant as intended.
>
> ilmar
>

---

From: Ilmar Wilbers <[email-masked]>
Date: Mon, 01 Sep 2008 13:06:06 +0200

What's wrong with tempfile.gettempdir()? I'm sure that mkdtemp is a 
better idea, I am just not sure why?

ilmar

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Mon, 1 Sep 2008 13:12:26 +0200

On my system, instant currently creates the directory:
  /tmp/instant

If I run two processes at the same time, or if I and Kent run stuff
at a server at the same time, this may lead to corrupt data.

Compared to this:

In [5]: tempfile.mkdtemp("instant")
Out[5]: '/tmp/tmpOFJwuTinstant'

In [6]: tempfile.mkdtemp("instant")
Out[6]: '/tmp/tmpk9f4xjinstant'

In [7]: tempfile.mkdtemp("instant")
Out[7]: '/tmp/tmpQ63f-Tinstant'

which gives a unique name each time.

-- 
Martin

2008/9/1 Ilmar Wilbers <[email-masked]>:
> What's wrong with tempfile.gettempdir()? I'm sure that mkdtemp is a better
> idea, I am just not sure why?
>
> ilmar
>

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Mon, 1 Sep 2008 13:20:29 +0200

However, with two processes, there will still be a race
condition during modification of the ~/.instant contents.
Not sure if there's an easy way to handle that.
We'll need some sort of locking mechanism on disk.

Since two users will have different cache directories,
this won't be a problem in that case, and better tempdir
naming is enough.

-- 
Martin

---

From: Anders Logg <[email-masked]>
Date: Mon, 1 Sep 2008 13:44:21 +0200

> this won't be a problem in that case, and better tempdir

How likely is it that two people compile a form on the same machine
and make a call to Instant within the time it takes to create a
directory?

-- 
Anders

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Mon, 1 Sep 2008 14:00:02 +0200

> and make a call to Instant within the time it takes to create a

Not very likely. But on e.g. marawa and potassium it may happen.
If Instant is going to be as robust as possible, it should be handled.
Not worth spending a lot of time on though...

However, the problem I state above can occur when a single user
on a single computer runs two processes compiling the same form,
where the form has not been cached before. One example comes to
mind: Running Python MPI codes could lead to this problem.

--
Martin

---

From: Anders Logg <[email-masked]>
Date: Mon, 1 Sep 2008 14:00:59 +0200

> mind: Running Python MPI codes could lead to this problem.

ok.

-- 
Anders