Permalink
Browse files

Perfomance improvments: track attributes for each source, fix select_…

…attr

Delete db-file, use file with schema instead
Fix mspec
Fix reset_db
Ignore iui and jqury for BB
  • Loading branch information...
1 parent 3f31314 commit d43738015fd834b093c1198ee4cf5b0d747ec4d3 @genywind genywind committed Aug 11, 2009
Showing with 747 additions and 179 deletions.
  1. +2 −1 .gitignore
  2. +6 −1 Rakefile
  3. +1 −0 platform/android/build/RubyVM_build.files
  4. +4 −0 platform/bb/Hsqldb/src/org/hsqldb/persist/Cache.java
  5. +1 −1 platform/bb/Hsqldb/src/org/hsqldb/persist/DataFileCache.java
  6. +1 −0 platform/bb/RubyVM/RubyVM.jdp
  7. +1 −0 platform/bb/build/RubyVM_build.files
  8. +3 −0 platform/bb/rhodes/rhodes.jdp
  9. +1 −1 platform/shared/build/build.xml
  10. +7 −4 platform/shared/db/DBAdapter.cpp
  11. +55 −3 platform/shared/ruby/ext/rho/rhoruby.c
  12. +5 −0 platform/shared/ruby/ext/rho/rhoruby.h
  13. +16 −20 platform/shared/ruby/ext/sqlite3_api/sqlite3_api_wrap.c
  14. +4 −0 platform/shared/ruby/ext/system/system_properties.c
  15. +2 −2 platform/shared/ruby/thread_win32.c
  16. +13 −1 platform/shared/ruby/vm_core.h
  17. +30 −0 platform/shared/rubyJVM/src/com/rho/Mutex.java
  18. +26 −0 platform/shared/rubyJVM/src/com/rho/RhoRuby.java
  19. +3 −1 platform/shared/rubyJVM/src/com/rho/db/DBAdapter.java
  20. +13 −7 platform/shared/rubyJVM/src/com/rho/net/NetRequest.java
  21. +3 −3 platform/shared/rubyJVM/src/com/rho/sync/SyncEngine.java
  22. +41 −31 platform/shared/rubyJVM/src/com/rho/sync/SyncSource.java
  23. +70 −0 platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyMutex.java
  24. +3 −2 platform/shared/rubyJVM/src/com/xruby/runtime/lang/RubyRuntime.java
  25. +21 −3 platform/shared/rubyJVM/src/javolution/io/UTF8StreamReader.java
  26. +3 −3 platform/shared/sync/SyncEngine.cpp
  27. +1 −1 platform/shared/sync/SyncEngine.h
  28. +28 −18 platform/shared/sync/SyncSource.cpp
  29. +16 −7 platform/shared/sync/syncthread.cpp
  30. +7 −6 platform/shared/sync/syncthread.h
  31. +7 −0 rhodes/rhodes-build/lib/tasks/blackberry.rake
  32. +38 −0 rhodes/rhodes-build/res/prebuilt/common/db/syncdb.schema
  33. BIN rhodes/rhodes-build/res/prebuilt/common/db/syncdb.sqlite
  34. +8 −4 rhodes/rhodes-framework/lib/rho/rho.rb
  35. +15 −1 rhodes/rhodes-framework/lib/rho/rhoutils.rb
  36. +1 −0 rhodes/rhodes-framework/lib/rhom/rhom.rb
  37. +1 −1 rhodes/rhodes-framework/lib/rhom/rhom_object.rb
  38. +286 −57 rhodes/rhodes-framework/lib/rhom/rhom_object_factory.rb
  39. +4 −0 rhodes/rhodes-framework/spec/app/spec/rho_spec.rb
View
@@ -20,6 +20,8 @@ platform/win32/bin/*
platform/wm/target/*
platform/wm/build/cleanup.js
platform/iphone/*/rholog.txt
+platform/win32/**/*.pch
+platform/wm/**/*.pch
platform/bb/.metadata/*
platform/bb/bin/*
@@ -71,7 +73,6 @@ platform/shared/*/bin
*.idb
*.lib
-*.pch
*.mode1v3
*.pbxuser
*.CAB
View
@@ -55,7 +55,12 @@ namespace "build" do
cp_r app + '/public', File.join($srcdir,'apps')
cp app + '/rhoconfig.txt', File.join($srcdir,'apps')
-
+ chdir File.join($srcdir,'apps/public')
+ rm_rf 'js/iui'
+ Dir.glob("js/jquery*").each {|f| rm_rf f}
+ Dir.glob("js/prototype*").each {|f| rm f}
+ chdir startdir
+
#create manifest
dir = File.join($srcdir, 'apps')
fname = "config.rb"
@@ -111,6 +111,7 @@ platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyThreadGroup.java
platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyTime.java
platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyTopSelf.java
platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyTypesUtil.java
+platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyMutex.java
platform/shared/rubyJVM/src/com/xruby/runtime/lang/annotation/DummyMethod.java
platform/shared/rubyJVM/src/com/xruby/runtime/lang/annotation/RubyAllocMethod.java
platform/shared/rubyJVM/src/com/xruby/runtime/lang/annotation/RubyLevelClass.java
@@ -173,7 +173,11 @@ private synchronized void cleanUp() throws IOException {
}
cacheMap.setAccessCountFloor(accessTarget);
+ //RHO
+ dataFileCache.getJournal().start();
saveRows(savecount);
+ dataFileCache.getJournal().stop();
+ //RHO
}
private synchronized void saveRows(int count) throws IOException {
@@ -163,7 +163,7 @@ protected void initParams(Database database,
dataFile = null;
}
- private com.rho.db.Journal getJournal()throws IOException {
+ public com.rho.db.Journal getJournal()throws IOException {
return ((ScaledRAFile)dataFile).getJournal();
}
@@ -118,6 +118,7 @@ ExcludeFromBuildAll=0
..\..\shared\rubyJVM\src\com\xruby\runtime\builtin\RubyIOPipeSourceExecutor.java
..\..\shared\rubyJVM\src\com\xruby\runtime\builtin\RubyMatchData.java
..\..\shared\rubyJVM\src\com\xruby\runtime\builtin\RubyMethodValue.java
+..\..\shared\rubyJVM\src\com\xruby\runtime\builtin\RubyMutex.java
..\..\shared\rubyJVM\src\com\xruby\runtime\builtin\RubyNumeric.java
..\..\shared\rubyJVM\src\com\xruby\runtime\builtin\RubyProc.java
..\..\shared\rubyJVM\src\com\xruby\runtime\builtin\RubyRandom.java
@@ -111,6 +111,7 @@ platform\shared\rubyJVM\src\com\xruby\runtime\builtin\RubyThreadGroup.java
platform\shared\rubyJVM\src\com\xruby\runtime\builtin\RubyTime.java
platform\shared\rubyJVM\src\com\xruby\runtime\builtin\RubyTopSelf.java
platform\shared\rubyJVM\src\com\xruby\runtime\builtin\RubyTypesUtil.java
+platform\shared\rubyJVM\src\com\xruby\runtime\builtin\RubyMutex.java
platform\shared\rubyJVM\src\com\xruby\runtime\lang\annotation\DummyMethod.java
platform\shared\rubyJVM\src\com\xruby\runtime\lang\annotation\RubyAllocMethod.java
platform\shared\rubyJVM\src\com\xruby\runtime\lang\annotation\RubyLevelClass.java
@@ -18,6 +18,9 @@ AutoRestart=0
[DefFiles
]
[DependsOn
+Hsqldb
+RhoBundle
+RubyVM
]
ExcludeFromBuildAll=0
[Files
@@ -101,7 +101,7 @@
<target name="bundleDB" depends="bundleCommon">
<copy todir="${src.dir}/db">
<fileset dir="../../../rhodes/rhodes-build/res/prebuilt/common/db">
- <include name="**/*.sqlite" />
+ <include name="**/*.*" />
</fileset>
</copy>
</target>
@@ -113,6 +113,7 @@ sqlite3_stmt* CDBAdapter::createInsertStatement(rho::db::CDBResult& res, const S
if ( !checkDbError(rc) )
return 0;
+ int nBindCol = 1;
for (int nCol = 0; nCol < nColCount; nCol++ )
{
int nColType = sqlite3_column_type(res.getStatement(),nCol);
@@ -122,20 +123,21 @@ sqlite3_stmt* CDBAdapter::createInsertStatement(rho::db::CDBResult& res, const S
switch(nColType){
case SQLITE_NULL:
- sqlite3_bind_text(stInsert, nCol, null, -1, SQLITE_TRANSIENT);
+ rc = sqlite3_bind_text(stInsert, nBindCol, null, -1, SQLITE_TRANSIENT);
break;
case SQLITE_INTEGER:
{
sqlite_int64 nValue = sqlite3_column_int64(res.getStatement(), nCol);
- sqlite3_bind_int64(stInsert, nCol, nValue);
+ rc = sqlite3_bind_int64(stInsert, nBindCol, nValue);
break;
}
default:{
char* szValue = (char *)sqlite3_column_text(res.getStatement(), nCol);
- sqlite3_bind_text(stInsert, nCol, szValue, -1, SQLITE_TRANSIENT);
+ rc = sqlite3_bind_text(stInsert, nBindCol, szValue, -1, SQLITE_TRANSIENT);
break;
}
}
+ nBindCol++;
}
return stInsert;
@@ -226,7 +228,8 @@ static const char* g_szDbSchema =
" last_inserted_size int default 0,"
" last_deleted_size int default 0,"
" last_sync_duration int default 0,"
- " last_sync_success int default 0);"
+ " last_sync_success int default 0,"
+ " source_attribs varchar default NULL);"
"CREATE INDEX by_attrib_utype on object_values (attrib,update_type);"
"CREATE INDEX by_src_type ON object_values (source_id, attrib_type, object);"
"CREATE INDEX by_src_utype on object_values (source_id,update_type);"
@@ -45,10 +45,39 @@ static VALUE framework;
static ID framework_mid;
static ID framework_mid2;
+static VALUE classRhomAttribManager;
+static ID midRhomAttribManager_save;
+static ID midRhomAttribManager_delete_attribs;
+static ID midRhomAttribManager_add_attrib;
+
static char* rb_type_to_s(VALUE obj);
+extern int ruby_thread_set_native(rb_thread_t *th);
+extern int native_mutex_lock(rb_thread_lock_t *);
+
+void RhoRubyThreadStart()
+{
+ rb_thread_t *th;
+
+ VALUE self = rb_thread_alloc(rb_cThread);
+ GetThreadPtr(self, th);
+
+ ruby_thread_init_stack(th);
+ ruby_thread_set_native(th);
+
+ rb_gc_register_mark_object(self);
+
+ //native_mutex_lock(&th->vm->global_vm_lock);
+}
+
+void RhoRubyThreadStop()
+{
+ //rb_thread_t *th = GET_THREAD();
+ //native_mutex_unlock(&th->vm->global_vm_lock);
+}
void RhoRubyStart()
{
+ VALUE moduleRhom;
#ifdef HAVE_LOCALE_H
setlocale(LC_CTYPE, "");
#endif
@@ -103,9 +132,17 @@ void RhoRubyStart()
#endif
rb_gc_register_mark_object(framework);
- CONST_ID(framework_mid, "serve");
- CONST_ID(framework_mid2, "serve_index");
-
+
+ CONST_ID(framework_mid, "serve");
+ CONST_ID(framework_mid2, "serve_index");
+
+ moduleRhom = rb_const_get(rb_cObject, rb_intern("Rhom"));
+ classRhomAttribManager = rb_const_get(moduleRhom, rb_intern("RhomAttribManager"));
+
+ CONST_ID(midRhomAttribManager_save, "save");
+ CONST_ID(midRhomAttribManager_delete_attribs, "delete_attribs");
+ CONST_ID(midRhomAttribManager_add_attrib, "add_attrib");
+
#ifdef ENABLE_RUBY_VM_STAT
g_collect_stat = 0;
#endif
@@ -240,6 +277,21 @@ VALUE callServeIndex(char* index_name) {
return callres;
}
+void RhoRuby_RhomAttribManager_save(int nSrcID)
+{
+ rb_funcall(classRhomAttribManager, midRhomAttribManager_save, 1, INT2FIX(nSrcID));
+}
+
+void RhoRuby_RhomAttribManager_delete_attribs(int nSrcID,unsigned __int64 objID)
+{
+ rb_funcall(classRhomAttribManager, midRhomAttribManager_delete_attribs, 2, INT2FIX(nSrcID), ULL2NUM(objID) );
+}
+
+void RhoRuby_RhomAttribManager_add_attrib(int nSrcID,const char* szAttrib)
+{
+ rb_funcall(classRhomAttribManager, midRhomAttribManager_add_attrib, 2, INT2FIX(nSrcID), rb_str_new2(szAttrib) );
+}
+
static char*
rb_type_to_s(VALUE obj)
{
@@ -22,6 +22,8 @@ typedef unsigned long VALUE;
#endif //!RUBY_RUBY_H
void RhoRubyStart();
+void RhoRubyThreadStart();
+void RhoRubyThreadStop();
VALUE getnil();
VALUE createHash();
@@ -36,6 +38,9 @@ void releaseValue(VALUE val);
VALUE callFramework(VALUE hashReq);
VALUE callServeIndex(char* index_name);
+void RhoRuby_RhomAttribManager_save(int nSrcID);
+void RhoRuby_RhomAttribManager_delete_attribs(int nSrcID,unsigned __int64 objID);
+void RhoRuby_RhomAttribManager_add_attrib(int nSrcID,const char* szAttrib);
void RhoRubyStop();
@@ -8,17 +8,18 @@
static VALUE mSqlite3;
static VALUE mDatabase;
-extern int rho_sync_openDB(const char* szDBPath, void ** ppDB);
-extern int rho_sync_closeDB(void * pDB);
-extern int rho_db_startUITransaction(void * pDB);
-extern int rho_db_commitUITransaction(void * pDB);
-extern int rho_db_rollbackUITransaction(void * pDB);
-extern int rho_db_destroy_table(void * pDB, const char* szTableName);
+extern int rho_sync_openDB(const char* szDBPath);
+extern int rho_sync_closeDB();
+extern int rho_db_startUITransaction();
+extern int rho_db_commitUITransaction();
+extern int rho_db_rollbackUITransaction();
+extern int rho_db_destroy_table(const char* szTableName);
+extern void* rho_db_get_handle();
static VALUE db_allocate(VALUE klass)
{
sqlite3 **db = malloc(sizeof(sqlite3 **));
- return Data_Wrap_Struct(klass, 0, 0, db);
+ return Data_Wrap_Struct(klass, 0, 0, 0);
}
static VALUE db_init(int argc, VALUE *argv, VALUE self)
@@ -33,7 +34,7 @@ static VALUE db_init(int argc, VALUE *argv, VALUE self)
Data_Get_Struct(self, sqlite3 *, ppDB);
szDbName = STR2CSTR(argv[0]);
- result = (int)rho_sync_openDB(szDbName,(void**)ppDB);//sqlite3_open(szDbName,ppDB);
+ result = (int)rho_sync_openDB(szDbName);//sqlite3_open(szDbName,ppDB);
if ( result != SQLITE_OK )
rb_raise(rb_eArgError, "could open database:%d",result);
@@ -49,9 +50,8 @@ static VALUE db_close(int argc, VALUE *argv, VALUE self){
rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc);
Data_Get_Struct(self, sqlite3 *, ppDB);
- db = *ppDB;
- rc = rho_sync_closeDB(db);//sqlite3_close(db);
+ rc = rho_sync_closeDB();//sqlite3_close(db);
return INT2NUM(rc);
}
@@ -65,9 +65,8 @@ static VALUE db_start_transaction(int argc, VALUE *argv, VALUE self){
rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc);
Data_Get_Struct(self, sqlite3 *, ppDB);
- db = *ppDB;
- rc = rho_db_startUITransaction(db);
+ rc = rho_db_startUITransaction();
return INT2NUM(rc);
}
@@ -81,9 +80,8 @@ static VALUE db_commit(int argc, VALUE *argv, VALUE self){
rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc);
Data_Get_Struct(self, sqlite3 *, ppDB);
- db = *ppDB;
- rc = rho_db_commitUITransaction(db);
+ rc = rho_db_commitUITransaction();
return INT2NUM(rc);
}
@@ -97,9 +95,8 @@ static VALUE db_rollback(int argc, VALUE *argv, VALUE self){
rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc);
Data_Get_Struct(self, sqlite3 *, ppDB);
- db = *ppDB;
- rc = rho_db_rollbackUITransaction(db);
+ rc = rho_db_rollbackUITransaction();
return INT2NUM(rc);
}
@@ -129,10 +126,9 @@ static VALUE db_destroy_table(int argc, VALUE *argv, VALUE self)
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc);
Data_Get_Struct(self, sqlite3 *, ppDB);
- db = *ppDB;
szTableName = RSTRING_PTR(argv[0]);
- rc = rho_db_destroy_table(db,szTableName);
+ rc = rho_db_destroy_table(szTableName);
return INT2NUM(rc);
}
@@ -152,15 +148,15 @@ static VALUE db_execute(int argc, VALUE *argv, VALUE self)
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc);
Data_Get_Struct(self, sqlite3 *, ppDB);
- db = *ppDB;
+ db = (sqlite3 *)rho_db_get_handle();
sql = RSTRING_PTR(argv[0]);
RAWTRACE1("db_execute: %s", sql);
if ( (nRes = sqlite3_prepare_v2(db, sql, -1, &statement, NULL)) != SQLITE_OK)
{
szErrMsg = sqlite3_errmsg(db);
- rb_raise(rb_eArgError, "could not prepare statement: %d",nRes);
+ rb_raise(rb_eArgError, "could not prepare statement: %d; Message: %s",nRes, (szErrMsg?szErrMsg:""));
}
while(sqlite3_step(statement) == SQLITE_ROW) {
@@ -38,3 +38,7 @@ char* get_property(char* property) {
return NULL;
}
+//TODO :rho_syscall
+VALUE rho_syscall(const char* callname, int nparams, char** param_names, char** param_values) {
+ return Qnil;
+}
@@ -32,13 +32,13 @@ static void native_cond_wait(rb_thread_cond_t *cond, rb_thread_lock_t *mutex);
static void native_cond_initialize(rb_thread_cond_t *cond);
static void native_cond_destroy(rb_thread_cond_t *cond);
-static rb_thread_t *
+rb_thread_t *
ruby_thread_from_native(void)
{
return TlsGetValue(ruby_native_thread_key);
}
-static int
+int
ruby_thread_set_native(rb_thread_t *th)
{
return TlsSetValue(ruby_native_thread_key, th);
@@ -601,9 +601,21 @@ NOINLINE(void rb_gc_save_machine_context(rb_thread_t *));
#if RUBY_VM_THREAD_MODEL == 2
RUBY_EXTERN rb_thread_t *ruby_current_thread;
extern rb_vm_t *ruby_current_vm;
+//RHO
+extern rb_thread_t * ruby_thread_from_native(void);
+inline rb_thread_t * __getCurrentThread()
+{
+ rb_thread_t * res = ruby_thread_from_native();
+ if ( res )
+ return res;
+
+ return ruby_current_thread;
+}
#define GET_VM() ruby_current_vm
-#define GET_THREAD() ruby_current_thread
+#define GET_THREAD() __getCurrentThread()
+//ruby_current_thread
+//RHO
#define rb_thread_set_current_raw(th) (void)(ruby_current_thread = (th))
#define rb_thread_set_current(th) do { \
rb_thread_set_current_raw(th); \
Oops, something went wrong.

0 comments on commit d437380

Please sign in to comment.