Question about clojure.lang.Compiler.writeClassFile()

52 views
Skip to first unread message

Laurent PETIT

unread,
Feb 6, 2009, 3:35:22 AM2/6/09
to clo...@googlegroups.com
Hello,

I have a problem for implementing the auto-compile feature of clojuredev eclipse plugin.

My problem is that it seems that the function 'compile returns very fast to the clojure dev builder, and when the builder refreshes the workspace (operation needed to "see" the newly compiled classes), it's ... to early !!

I guess something could be done in clojure.lang.Compiler.writeClassFile() method to avoid this situation.
The idea could be to make it guarantee that whenever it returns, the changes are not only flushed to the OS, but also written on disk.
I don't know if this could have significant performance impacts, so maybe it could be necessary to make this behaviour dependent on some new parameter, or on a global var (something like *ensure-filesystem-sync*).

I don't have clojuredev yet to test, but the modification would be something like (new end of clojure.lang.Compiler.writeClassFile()) (case without conditional on the sync mechanism) :
    FileOutputStream cfs = new FileOutputStream(cf); /// <<<<<<<< change cfs type to FileOutputStream
    try
        {
        cfs.write(bytecode);
        cfs.flush(); // <<<<<<<<<<<<<<<<<<<<<<<<<<< flush cfs content
        cfs.getFD().sync(); // <<<<<<<<<<<<<<<<<<<<<<<<< call cfs FileDescriptor's sync() method
        }
    finally
        {
        cfs.close();
        cf.lastModified();
        }


If it is proved that it solves the above mentioned problem, would it be an acceptable patch ?
Or, if you can think of another way to solve the general problem, please tell, I'll be glad to know about it !

Regards,

--
Laurent PETIT

Laurent PETIT

unread,
Feb 6, 2009, 2:42:37 PM2/6/09
to clo...@googlegroups.com
Hello,

I could test the patch, it works really well. With it, no need to implement periodic polling, which is really a bad solution when on e can avoid it!

Still don't know if there could be a performance impact that would require to have this as an optional behaviour.

Rich, please do you think it is an acceptable patch ? If so, I'll then send my contributor agreement as needed, and open an issue.

Thanks in advance,

--
Laurent

2009/2/6 Laurent PETIT <lauren...@gmail.com>

Rich Hickey

unread,
Feb 7, 2009, 9:51:06 AM2/7/09
to Clojure


On Feb 6, 2:42 pm, Laurent PETIT <laurent.pe...@gmail.com> wrote:
> Hello,
>
> I could test the patch, it works really well. With it, no need to implement
> periodic polling, which is really a bad solution when on e can avoid it!
>
> Still don't know if there could be a performance impact that would require
> to have this as an optional behaviour.
>
> Rich, please do you think it is an acceptable patch ? If so, I'll then send
> my contributor agreement as needed, and open an issue.
>
> Thanks in advance,
>
> --
> Laurent
>
> 2009/2/6 Laurent PETIT <laurent.pe...@gmail.com>
I've added a call to sync in SVN 1252 - thanks for the report.

Rich
Reply all
Reply to author
Forward
0 new messages