[m-dev.] diff: improve performance of Aditi bulk insertions
Simon TAYLOR
stayl at cs.mu.OZ.AU
Wed May 24 17:13:02 AEST 2000
Estimated hours taken: 1
Generate RL procedures to handle bulk insertions, as is done for
deletions and modifications. This change is needed because the
Aditi API function to perform bulk insertions is very slow.
compiler/rl_out.pp:
Generate a procedure for each base relation to handle
bulk insertion.
compiler/rl.m:
Add `rl__get_insert_proc_name' to return the name of the
automatically generate insertion procedure for a base relation.
compiler/call_gen.m:
Set up the procedure name argument to `do_aditi_bulk_insert'.
Index: call_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/call_gen.m,v
retrieving revision 1.139
diff -u -u -r1.139 call_gen.m
--- call_gen.m 2000/04/14 08:37:42 1.139
+++ call_gen.m 2000/05/23 08:05:25
@@ -478,7 +478,10 @@
in, out) is det.
call_gen__aditi_insert_delete_modify_setup(bulk_insert, PredId, SetupCode) -->
- call_gen__setup_base_relation_name(PredId, SetupCode).
+ call_gen__setup_base_relation_name(PredId, RelNameCode),
+ call_gen__setup_update_proc_name(rl__get_insert_proc_name,
+ PredId, reg(r, 2), ProcNameCode),
+ { SetupCode = tree(RelNameCode, ProcNameCode) }.
call_gen__aditi_insert_delete_modify_setup(delete(_), PredId, SetupCode) -->
call_gen__setup_base_relation_name(PredId, RelNameCode),
call_gen__setup_update_proc_name(rl__get_delete_proc_name,
Index: rl.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rl.m,v
retrieving revision 1.13
diff -u -u -r1.13 rl.m
--- rl.m 2000/04/17 10:32:09 1.13
+++ rl.m 2000/05/22 06:57:00
@@ -593,11 +593,11 @@
:- pred rl__get_entry_proc_name(module_info::in, pred_proc_id::in,
rl_proc_name::out) is det.
- % rl__get_modify_proc_name(ModuleInfo, BaseRelationPredId, ProcName).
+ % rl__get_insert_proc_name(ModuleInfo, BaseRelationPredId, ProcName).
%
- % Get the name of the RL procedure used to apply a modification
+ % Get the name of the RL procedure used to apply a bulk insertion
% to a base relation.
-:- pred rl__get_modify_proc_name(module_info::in,
+:- pred rl__get_insert_proc_name(module_info::in,
pred_id::in, rl_proc_name::out) is det.
% rl__get_delete_proc_name(ModuleInfo, BaseRelationPredId, ProcName).
@@ -607,6 +607,13 @@
:- pred rl__get_delete_proc_name(module_info::in,
pred_id::in, rl_proc_name::out) is det.
+ % rl__get_modify_proc_name(ModuleInfo, BaseRelationPredId, ProcName).
+ %
+ % Get the name of the RL procedure used to apply a modification
+ % to a base relation.
+:- pred rl__get_modify_proc_name(module_info::in,
+ pred_id::in, rl_proc_name::out) is det.
+
% rl__get_c_interface_proc_name(ModuleInfo, PredProcId, ProcName).
%
% Get the name of the RL procedure used to call an Aditi
@@ -1071,13 +1078,17 @@
prog_out__sym_name_to_string(PredModule, PredModuleStr),
ProcName = rl_proc_name(Owner, PredModuleStr, ProcLabelStr, 2).
-rl__get_modify_proc_name(ModuleInfo, PredId, ProcName) :-
+rl__get_insert_proc_name(ModuleInfo, PredId, ProcName) :-
rl__get_update_proc_name(ModuleInfo, PredId,
- "Aditi_Modify_Proc_For_", ProcName).
+ "Aditi_Insert_Proc_For_", ProcName).
rl__get_delete_proc_name(ModuleInfo, PredId, ProcName) :-
rl__get_update_proc_name(ModuleInfo, PredId,
"Aditi_Delete_Proc_For_", ProcName).
+
+rl__get_modify_proc_name(ModuleInfo, PredId, ProcName) :-
+ rl__get_update_proc_name(ModuleInfo, PredId,
+ "Aditi_Modify_Proc_For_", ProcName).
:- pred rl__get_update_proc_name(module_info::in,
pred_id::in, string::in, rl_proc_name::out) is det.
Index: rl_out.pp
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rl_out.pp,v
retrieving revision 1.13
diff -u -u -r1.13 rl_out.pp
--- rl_out.pp 2000/04/14 08:38:24 1.13
+++ rl_out.pp 2000/05/24 06:47:17
@@ -373,21 +373,23 @@
{ ModuleName = PredModule },
{ hlds_pred__pred_info_is_base_relation(PredInfo) }
->
+ rl_out__generate_update_proc(insert, PredId, PredInfo),
rl_out__generate_update_proc(delete, PredId, PredInfo),
rl_out__generate_update_proc(modify, PredId, PredInfo)
;
[]
).
-:- type delete_or_modify
- ---> delete
+:- type update_type
+ ---> insert
+ ; delete
; modify
.
-:- pred rl_out__generate_update_proc(delete_or_modify::in, pred_id::in,
+:- pred rl_out__generate_update_proc(update_type::in, pred_id::in,
pred_info::in, rl_out_info::in, rl_out_info::out) is det.
-rl_out__generate_update_proc(DeleteOrModify, PredId, PredInfo) -->
+rl_out__generate_update_proc(UpdateType, PredId, PredInfo) -->
{ map__init(Relations) },
rl_out_info_init_proc(Relations),
@@ -402,10 +404,13 @@
PermanentAddr, OpenPermanentCode, UnsetPermanentCode),
{
- DeleteOrModify = delete,
+ UpdateType = insert,
InputRelTypes = ArgTypes
;
- DeleteOrModify = modify,
+ UpdateType = delete,
+ InputRelTypes = ArgTypes
+ ;
+ UpdateType = modify,
list__append(ArgTypes, ArgTypes, InputRelTypes)
},
@@ -421,7 +426,22 @@
{ LockSpec = 0 }, % default lock spec
(
- { DeleteOrModify = delete },
+ { UpdateType = insert },
+ { rl__get_insert_proc_name(ModuleInfo, PredId, ProcName) },
+ rl_out_info_get_next_materialise_id(MaterialiseId),
+ { InsertCode =
+ node([
+ rl_PROC_materialise(MaterialiseId),
+ rl_PROC_stream,
+ rl_PROC_var(InputRelAddr, LockSpec),
+ rl_PROC_stream_end,
+
+ rl_PROC_var_list_cons(PermanentAddr, LockSpec),
+ rl_PROC_var_list_nil
+ ]) },
+ { DeleteCode = empty }
+ ;
+ { UpdateType = delete },
{ rl__get_delete_proc_name(ModuleInfo, PredId, ProcName) },
{ DeleteInputStream =
node([
@@ -429,9 +449,11 @@
rl_PROC_var(InputRelAddr, LockSpec),
rl_PROC_stream_end
]) },
- { InsertCode = empty }
+ { InsertCode = empty },
+ rl_out__generate_delete_code(PermanentAddr, Indexes, ArgTypes,
+ PermSchemaOffset, DeleteInputStream, DeleteCode)
;
- { DeleteOrModify = modify },
+ { UpdateType = modify },
{ rl__get_modify_proc_name(ModuleInfo, PredId, ProcName) },
rl_out__generate_modify_project_exprn(ArgTypes,
PermSchemaOffset, one, DeleteProjectExpr),
@@ -459,7 +481,10 @@
rl_PROC_stream_end
]) },
+ rl_out__generate_delete_code(PermanentAddr, Indexes, ArgTypes,
+ PermSchemaOffset, DeleteInputStream, DeleteCode),
+ rl_out_info_get_next_materialise_id(MaterialiseId),
{ InsertCode =
node([
%
@@ -468,7 +493,7 @@
% inserting the result into the base
% relation.
%
- rl_PROC_materialise(1),
+ rl_PROC_materialise(MaterialiseId),
rl_PROC_stream,
rl_PROC_project_tee,
@@ -486,8 +511,6 @@
]) }
),
- rl_out__generate_delete_code(PermanentAddr, Indexes, ArgTypes,
- PermSchemaOffset, DeleteInputStream, DeleteCode),
{ Codes = tree(
%
@@ -501,7 +524,8 @@
tree(DeleteCode,
%
- % Do the insertion for an `aditi_bulk_modify' goal.
+ % Do the insertion for an `aditi_bulk_modify'
+ % or `aditi_bulk_insert' goal.
%
tree(InsertCode,
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list